<?php
include("../include/config.inc.php");

$consql.="";
$sql = "select count(*) as count from ".tableprefix."news where 1=1 ".$consql;
$row=$db->fetch_array($db->query($sql));
$count=$row["count"];
$page=new ShowPage;
$page->PageSize=20;
$page->Total=$count;
$page->LinkAry = array("id"=>$id);
$sql="select * from ".tableprefix."news where 1=1 ".$consql." limit ".$page->OffSet();
$result=$db->query($sql);
$showpage= $page->ShowLink();
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" href="../css/frameCss/font-awesome-4.7.0/css/font-awesome.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/frameCss/animate.css"/>
		<link rel="stylesheet" type="text/css" href="../css/frameCss/mui.min.css"/>
		<link rel="stylesheet" type="text/css" href="../css/public.css"/>
		<link rel="stylesheet" type="text/css" href="../css/index.css"/>
	</head>
	<body>
		<header></header>
		<div id="newsList-container-wrapper" class="animated fadeInLeft">
			<div id="newsList-container">
				<div class="newsList">
<?php     
if($count>0){
?>
<?php
while($row = $db->fetch_array($result)){
$userid=$row["userid"];

$s="SELECT * FROM ".tableprefix."store where member_id='$userid'";
$res=$db->query($s);
$store=$db->fetch_array($res);
?>
				
					<div class="mui-card news-box">
						<div class="mui-card-header mui-card-media">
							<a href="../store/index.php?id=<?php echo $store["store_id"];?>">
								<img src="<?php if($store["store_label"]==''){echo "../images/storenav_01.jpg";}else{echo "../".$store["store_label"];}?>"/>
							</a>
							<div class="mui-media-body">
								<span><?php echo $store["store_name"];?></span>
								<p>发表于 <?php echo date("Y-m-d",$row["createtime"]);?></p>
							</div>
						</div>
						<div class="mui-card-content" >
							<a href="shownews.php?id=<?php echo $row["id"];?>">
								<img src="../<?php echo $row["thumb"];?>" alt="<?php echo $row["title"];?>"/>
								<div class="mui-card-content-inner">
									<p style="color: #333;"><?php echo $row["title"];?></p>
								</div>
							</a>
						</div>
						<div class="mui-card-footer">
							<a href="shownews.php?id=<?php echo $row["id"];?>">
								<span class="mui-card-link">详细内容</span>
							</a>
						</div>
					</div>
<?php
}
?>

<?php
}else{
echo "<div style='padding:50px 0px;text-align:center;color:#990000;font-size:12px;'>没有找到合乎条件的记录</div>";
}
?>					
				</div>
			</div>
		</div>
		
		<script src="../js/frameJS/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/frameJS/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function(){
				
				//加载公共头部
				$('header').load('../commonTemplate/common-header.html');
				
				//防止用了mui后a标签失效
				mui('body').on('tap','a',function(){
				    window.top.location.href=this.href;
				});
				
				//上下拉刷新
				mui.init({
					pullRefresh: {
						container: '#newsList-container-wrapper',
						up: {
							contentrefresh: '正在加载...',
							callback: pullupRefresh
						}
					}
				});
				
				//上拉加载具体业务实现
				function pullupRefresh() {
					setTimeout(function() {
						mui('#newsList-container-wrapper').pullRefresh().endPullupToRefresh(); //参数为true代表没有更多数据了。
						var $div = $('<div class="mui-card news-box"><div class="mui-card-header mui-card-media"><a href="index.html"><img src="../images/img1.jpg"/></a><div class="mui-media-body"><span>waDe</span><p>发表于 2017-05-22 15:30</p></div></div><div class="mui-card-content" ><a href="showNews.html"><img src="../images/92191400.jpg" alt=""/><div class="mui-card-content-inner"><p style="color: #333;">这里显示文章摘要，让读者对文章内容有个粗略的概念...</p></div></a></div><div class="mui-card-footer"><a href="showNews.html"><span class="mui-card-link">详细内容</span></a></div></div>')
						$('.newsList','#newsList-container-wrapper').append($div)
					}, 1000);
				}
			})
		</script>
	</body>
</html>